#ifndef __BITSTREAM_STUFF
#define __BITSTREAM_STUFF

/*
 *   This file is part of ed_pvr.
 *
 *   ed_pvr is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   ed_pvr is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with ed_pvr.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifdef __cplusplus
    extern "C" {
#endif

#include <stdint.h>

struct bitstream_Struct
{
	uint32_t len;
	uint8_t * stream;
	uint32_t bit_offset;
};
typedef struct bitstream_Struct BITSTREAM;

BITSTREAM * bits_create(uint8_t *, uint32_t);
int8_t bits_reset(BITSTREAM *);
int8_t bits_get_next_bit(BITSTREAM *);
uint64_t bits_get_bit_count(BITSTREAM *, uint32_t, int8_t *);
int8_t bits_peek_next_bit(BITSTREAM *);
uint64_t bits_peek_bit_count(BITSTREAM *, uint32_t, int8_t *);
uint64_t bits_get_ue_golomb(BITSTREAM *, int8_t *);
int64_t bits_get_se_golomb(BITSTREAM *, int8_t *);
void bits_align_8(BITSTREAM *, int8_t *);
uint8_t bits_invert_byte(uint8_t);
uint32_t bits_get_be32(BITSTREAM *, int8_t *);
uint32_t bits_get_be24(BITSTREAM *, int8_t *);
uint16_t bits_get_be16(BITSTREAM *, int8_t *);
BITSTREAM * bits_create_put(uint8_t *, uint32_t);

#ifdef __cplusplus
    }
#endif


#endif
